<template>
  <div>
    <Card>
      <div class="textRight marginB10">
        <span class="marginR10">已选
          <span class="cBlue">{{selectMore.length}}</span>
          条数据
        </span>
        <Button type="primary" size="small" shape="circle" @click="huLAll" :disabled="!$app.judgeData(selectMore)">
          <Icon type="md-trash" size="16" />
          忽略
        </Button>
      </div>
      <Table
        :data="tableData"
        :columns="columns"
        stripe
        border
        class="marginB10"
        :loading="loading"
        @on-selection-change="onSelect"
        :height="$app.winHeight-220"
      ></Table>
      <Page
        :total="total"
        show-sizer
        show-total
        show-elevator
        size="small"
        :page-size="pageSize"
        :page-size-opts="$app.pageAll.pageSizeOpts"
        :current="page"
        @on-change="loadMore"
        @on-page-size-change="changePageSize"
      ></Page>
    </Card>
    
  </div>
</template>

<script>
import ListWarnInfo from "@$@/js/warnXT/ListWarnInfo";
export default {
  name: "ListWarnInfo_ZL",
  components: {},
  //1待缴申请费，2待补正，3审查意见待答复，4待办理登记
  props:['ListWarnInfo_type'],
  data() {
    let data = {
      tableData: [],
      columns: []
    };
    //分页相关
    let tool = {
      loading: true, //加载时显示转转
      total: 0, //总页数
      page: 1, //当前页码
      pageSize: $app.pageAll.pageSize, //分页条数，最低15条
      selectMore:[]
    };
    return Object.assign(data, tool); // 对象合并
  },
  mounted() {
    this.getData();
  },
  methods: {
    //获取数据
    getData() {
      // 清空原本的数据
      this.loading=true;
      this.columns=[];
      this.tableData=[];
      
      this.selectMore=[];//初始化的时候

      let {
        ListWarnInfo_type
      }=this;

      let { page, pageSize } = this;
      if(ListWarnInfo_type==1){
        $ajax.z_getPatentApplyFee({ page, pageSize }, resData => {
          this.ajaxBack(resData);
        });
      }else if(ListWarnInfo_type==2){
        $ajax.z_getPatentBz({ page, pageSize }, resData => {
          this.ajaxBack(resData);
        });
      }else if(ListWarnInfo_type==3){
        $ajax.z_getPatentOa({ page, pageSize }, resData => {
          this.ajaxBack(resData);
        });
      }else if(ListWarnInfo_type==4){
        $ajax.z_getPatentAuth({ page, pageSize }, resData => {
          this.ajaxBack(resData);
        });
      }
      
    },
    ajaxBack(resData){
      this.columns=ListWarnInfo.list(this);
      this.loading=false;
      this.tableData = resData.list;
      this.total = resData.total;
    },
    // 加载更多
    loadMore(page) {
      this.page = page;
      this.$nextTick(() => {
        this.getData();
      });
    },
    // 数据返回条
    changePageSize(pageSize) {
      this.pageSize = pageSize;
      this.page = 1;
      this.$nextTick(() => {
        this.getData();
      });
    },

    // 单个忽略
    huLA(obj){
      this.huXz({id:JSON.stringify([obj.id])})
    },

    // 触发忽略
    huXz(obj){


      let{ListWarnInfo_type}=this;
      switch(parseInt(ListWarnInfo_type)){
        case 1://1待缴申请费，2待补正，3审查意见待答复，4待办理登记
          $ajax.schedule_ignorePatentApplyFee(obj, res => {
            $app.toast(res.msg, true);
            this.page = 1;
            this.$nextTick(() => {
              this.getData();
            });
          });
          break;
        case 2:
          $ajax.schedule_ignorePatentBz(obj, res => {
            $app.toast(res.msg, true);
            this.page = 1;
            this.$nextTick(() => {
              this.getData();
            });
          });
          break;
        case 3:
          $ajax.schedule_ignorePatentOa(obj, res => {
            $app.toast(res.msg, true);
            this.page = 1;
            this.$nextTick(() => {
              this.getData();
            });
          });
          break;
        case 4:
          
          $ajax.schedule_ignorePatentAuth(obj, res => {
            $app.toast(res.msg, true);
            this.page = 1;
            this.$nextTick(() => {
              this.getData();
            });
          });
          break;
      }
    },
    

    // 集体忽略
    huLAll() {
      let { selectMore } = this;
      if ($app.judgeData(selectMore)) {
        $app.confirm("您确定忽略所选项目?", "温馨提示", {
          yesFun: () => {
            this.huXz({ id: JSON.stringify(selectMore) });
          }
        });
      } else {
        this.$Message.error({content: "请选择需忽略的项目"});
      }
    },
    // 多选模式触发
    onSelect(list, row) {
      let selectMore = [];
      list.forEach((val, i) => {
        selectMore.push(val.id);
      });
      this.selectMore = selectMore;
    },
  }
};
</script>

